1 ===============================================================================
2 WINDOWS FORMS APPLICATION : CSWinFormObjPersistence Project Overview
3 ===============================================================================
5 /////////////////////////////////////////////////////////////////////////////
8 The Object Persistance sample demonstrates how to persist an object's data
9 between instances, so that the data can be restored the next time the object
13 /////////////////////////////////////////////////////////////////////////////
16 1. Build the solution and run.
17 2. Enter some value to Name, Age, Address field
19 4. Run the app again. You can see these value keeps in the field.
22 /////////////////////////////////////////////////////////////////////////////
25 This sample uses a binaray file "Customer.bin" to store the information.
27 1. Create a class names Customer with some properties, and make the whole class
28 as serializable by adding the Serializable attribute on top of the class
30 If you do not want to persist a field, mark it as NonSerialized.
32 2. In the Form.Load event,check if the Customer.bin file exists, it the file
33 exists, use BinaryFormatter.Deserialize method to retrieve the data stored
34 in it, otherwise create a new instance of Customer class.
36 3. In the Form.FormClosing event,use BinaryFormatter.Serialize method to
37 serialize the customer information to the Customer.bin file.
40 /////////////////////////////////////////////////////////////////////////////
43 1. Walkthrough: Persisting an Object in Visual Basic .NET
44 http://msdn.microsoft.com/en-us/library/aa984468(VS.71).aspx
46 2. Windows Forms General FAQ.
47 http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/77a66f05-804e-4d58-8214-0c32d8f43191
50 /////////////////////////////////////////////////////////////////////////////